package com.sealer.pattern.behavioral.strategy;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by sealer on 17/04/05.
 */
public class Customer {
    private List<Double> drinks;
    private BillingStrategy billingStrategy;

    public Customer(BillingStrategy billingStrategy) {
        this.drinks = new ArrayList<>();
        this.billingStrategy = billingStrategy;
    }

    public void add(final double price, final int quantity) {
        drinks.add(billingStrategy.getActPrice(price * quantity));
    }

    public void printBill() {
        double sum = 0.0;
        for (Double d : drinks) {
            sum += d;
        }

        System.out.println("Total due: " + sum);
        drinks.clear();
    }

    public void setBillingStrategy(BillingStrategy billingStrategy) {
        this.billingStrategy = billingStrategy;
    }
}
